﻿<UserControl x:Class="ArchiSimple.Windows.View.MenuView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             xmlns:vm="clr-namespace:ArchiSimple.Windows.ViewModel"             
             xmlns:locale="clr-namespace:ArchiSimple.Windows"
             locale:Locator.Locate="vm:MenuViewModel"   
             d:DataContext="{d:DesignInstance vm:MenuViewModel, IsDesignTimeCreatable=True}">
    <UserControl.Resources>
        <locale:EnumToBooleanConverter x:Key="EnumToBooleanConverter"/>
        <locale:PlanObjectDataTemplateSelector x:Key="PlanObjectDataTemplateSelector" />
        <locale:PlanObjectStyleSelector x:Key="PlanObjectStyleSelector" />
        <ControlTemplate x:Key="MenuToggleButtonControlTemplate" TargetType="{x:Type ToggleButton}">
            <Grid Height="60" x:Name="buttonGrid">
                <VisualStateManager.VisualStateGroups>
                    <VisualStateGroup x:Name="CommonStates">
                        <VisualState x:Name="Normal">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="buttonGrid" Storyboard.TargetProperty="Height" To="60" Duration="0:0:0.5"  />
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Pressed"/>
                        <VisualState x:Name="Disabled">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="buttonGrid" Storyboard.TargetProperty="Height" To="0" Duration="0" />
                            </Storyboard>
                        </VisualState>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="FocusStates">
                        <VisualState x:Name="Focused"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="CheckStates">
                        <VisualState x:Name="Unchecked"/>
                        <VisualState x:Name="Checked">
                            <Storyboard>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="RectBlue">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                </ObjectAnimationUsingKeyFrames>
                                <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="ContentWhite">
                                    <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                                </ObjectAnimationUsingKeyFrames>
                            </Storyboard>
                        </VisualState>
                        <VisualState x:Name="Indeterminate"/>
                    </VisualStateGroup>
                    <VisualStateGroup x:Name="ValidationStates">
                        <VisualState x:Name="InvalidFocused"/>
                        <VisualState x:Name="InvalidUnfocused"/>
                    </VisualStateGroup>
                </VisualStateManager.VisualStateGroups>
                <Rectangle Fill="{StaticResource WhiteSolidColor}" />
                <ContentControl Content="{TemplateBinding Content}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="36" BorderThickness="0" Margin="10,0,0,0" Foreground="{StaticResource GraySolidColor}" />
                <Rectangle x:Name="RectBlue" Fill="{StaticResource BlueSolidColor}" Visibility="{x:Static Visibility.Collapsed}" />
                <ContentControl x:Name="ContentWhite" Content="{TemplateBinding Content}" HorizontalAlignment="Left" VerticalAlignment="Center" FontSize="36" Foreground="{StaticResource WhiteSolidColor}" BorderThickness="0" Margin="10,0,0,0" Visibility="Collapsed" />
            </Grid>
        </ControlTemplate>
        <DataTemplate x:Key="Room">
            <Border BorderThickness="1" BorderBrush="{StaticResource BlueSolidColor}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="60" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Border Background="{StaticResource BlueSolidColor}">
                        <TextBlock Margin="9,0,0,0" Text="Pièce" FontSize="36" Foreground="{StaticResource WhiteSolidColor}" />
                    </Border>
                    <Grid Grid.Row="1" Margin="10,16">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="Titre :" Grid.Row="0" FontSize="36" Foreground="{StaticResource GraySolidColor}" />
                        <TextBox Text="{Binding Title, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" />
                        <TextBlock Text="Couleur :" Grid.Row="2" Foreground="{StaticResource GraySolidColor}" />
                        <ComboBox Grid.Row="3" ItemsSource="{Binding ColorsAllowed}" SelectedValuePath="Color" SelectedValue="{Binding Color, Mode=TwoWay}">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Grid Height="35" Background="{StaticResource WhiteSolidColor}">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="29" />
                                            <ColumnDefinition Width="*" />
                                        </Grid.ColumnDefinitions>
                                        <Border>
                                            <Border.Background>
                                                <SolidColorBrush Color="{Binding Color}" />
                                            </Border.Background>
                                        </Border>
                                        <TextBlock Text="{Binding Name}" Grid.Column="1" />
                                    </Grid>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </Grid>
                </Grid>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="Wall">
            <Border BorderThickness="1" BorderBrush="{StaticResource BlueSolidColor}">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="60" />
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <Border Background="{StaticResource BlueSolidColor}">
                        <TextBlock Margin="9,0,0,0" Text="Mure" FontSize="36" Foreground="{StaticResource WhiteSolidColor}" />
                    </Border>
                    <Grid Grid.Row="1" Margin="10,16">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                            <RowDefinition Height="auto" />
                        </Grid.RowDefinitions>
                        <TextBlock Text="Dimension :" Grid.Row="0" FontSize="36" Foreground="{StaticResource GraySolidColor}" />
                        <TextBox Text="{Binding Size, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Grid.Row="1" />
                        <StackPanel Orientation="Horizontal" Grid.Row="2">
                            <TextBlock Text="A partir de :" />
                            <RadioButton IsChecked="{Binding SizeMode, ConverterParameter=Begin, Converter={StaticResource EnumToBooleanConverter}}" Content="A" />
                            <RadioButton IsChecked="{Binding SizeMode, ConverterParameter=End, Converter={StaticResource EnumToBooleanConverter}}" Content="B" />
                        </StackPanel>
                        <Button Grid.Row="3" Content="Supprimer" Command="{Binding DeleteCommand}" />
                    </Grid>
                </Grid>
            </Border>
        </DataTemplate>
        <DataTemplate x:Key="Point"/>
    </UserControl.Resources>
    <Grid Width="300">
        <StackPanel Margin="0,40,0,0">
            <ToggleButton Content="Fichier" Command="{Binding FileCommand}" IsChecked="{Binding IsFile}" Template="{StaticResource MenuToggleButtonControlTemplate}" HorizontalAlignment="Stretch" />
            <ToggleButton Content="Plan" Command="{Binding PlanCommand}" IsChecked="{Binding IsPlan}" Template="{StaticResource MenuToggleButtonControlTemplate}" IsEnabled="{Binding IsOpenPlan}" HorizontalAlignment="Stretch" />
            <ToggleButton Content="Quitter" Command="{Binding ExitCommand}" Template="{StaticResource MenuToggleButtonControlTemplate}" HorizontalAlignment="Stretch" />
            <ContentControl Content="{Binding CurrentPlanObject}" ContentTemplateSelector="{StaticResource PlanObjectDataTemplateSelector}" />
        </StackPanel>
    </Grid>
</UserControl>
